package com.azt.model;

import java.io.InputStream;
import java.util.Properties;

import com.azt.utils.BeanUtils;

public class OSSServer {
	private String key;
	private String secret;
	private String endpoint;
	private String bucket;
	private String accessURL;
	private String ossURL;

	private static OSSServer IMG_SERVER = null;
	private static OSSServer FILE_SERVER = null;
	static {
		try {
			IMG_SERVER = load(OSSServer.class
					.getResourceAsStream("/ossconfig/oss-img-server.properties"));
			FILE_SERVER = load(OSSServer.class
					.getResourceAsStream("/ossconfig/oss-file-server.properties"));
		} catch (Exception e) {
			System.exit(-1);
		}
	}

	private static OSSServer load(InputStream in) throws Exception {
		Properties props = new Properties();
		props.load(in);
		return BeanUtils.copyMap2Bean(new OSSServer(), props);
	}

	public static OSSServer getImgServer() {
		return IMG_SERVER;
	}

	public static OSSServer getFileServer() {
		return FILE_SERVER;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getSecret() {
		return secret;
	}

	public void setSecret(String secret) {
		this.secret = secret;
	}

	public String getEndpoint() {
		return endpoint;
	}

	public void setEndpoint(String endpoint) {
		this.endpoint = endpoint;
	}

	public String getAccessURL() {
		return accessURL;
	}

	public void setAccessURL(String accessURL) {
		this.accessURL = accessURL;
	}

	public String getBucket() {
		return bucket;
	}

	public void setBucket(String bucket) {
		this.bucket = bucket;
	}

	public String getOssURL() {
		return ossURL;
	}

	public void setOssURL(String ossURL) {
		this.ossURL = ossURL;
	}

}
